from fastapi import FastAPI
from app.config import settings
from app.routers import health, poster,pdf_upload
from fastapi.middleware.cors import CORSMiddleware

# venv\Scripts\activate 激活虚拟环境
# uvicorn app.main:app --reload --port 8000 启动服务

app = FastAPI(title=settings.PROJECT_NAME)

# 允许所有来源（生产环境应指定具体域名）
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 添加路由
app.include_router(health.router)
app.include_router(poster.router, prefix="/poster", tags=["poster"])
app.include_router(pdf_upload.router)

@app.on_event("startup")
async def startup():
    print(f"Starting {settings.PROJECT_NAME} in {settings.ENVIRONMENT} mode")